'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc., All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH USB_GET_MAX_PKTS_PER_ISOC_REQUEST 9F "Nov 10, 2016"
.SH NAME
usb_get_max_pkts_per_isoc_request \- Get maximum number of packets allowed per
isochronous request
.SH SYNOPSIS
.nf
#include <sys/usb/usba.h>



\fB\fR\fBuint_t\fR usb_get_max_pkts_per_isoc_request(\fBdev_info_t *\fR\fIdip\fR);
.fi

.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI)
.SH PARAMETERS
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 7n
Pointer to the device's \fBdev_info\fR structure.
.RE

.SH DESCRIPTION
The \fBusb_get_max_pkts_per_isoc_request()\fR function returns the maximum
number of isochronous packets per request that the host control driver can
support. This number can be used to determine the maximum amount of data which
can be handled by a single isochronous request. That length is found by:
.sp
.in +2
.nf
max = usb_get_max_pkts_per_isoc_request(dip) * endpoint_max_packet_size;
.fi
.in -2

.sp
.LP
where endpoint_max_packet_size is the wMaxPacketSize field of the isochronous
endpoint over which the transfer will take place.
.SH RETURN VALUES
On success, the \fBusb_get_max_pkts_per_isoc_request()\fR function returns the
maximum number of isochronous pkts per request. On failure it returns \fB0\fR.
The function fails if \fIdip\fR is NULL.
.SH CONTEXT
May be called from user, kernel or interrupt context.
.SH EXAMPLES
.in +2
.nf
/*
 * Set up to receive periodic isochronous data, requesting
 * the maximum amount for each transfer.
 */

int pkt;
/* Get max packet size from endpoint descriptor. */
uint_t ep_max_pkt_size = ep_descr.wMaxPacketSize;
uint_t isoc_pkts_count = usb_get_max_pkts_per_isoc_request(dip);

/*
 * Allocate an isoc request, specifying the max number of packets
 * and the greatest size transfer possible.
 */
usb_isoc_req_t *isoc_req = usb_alloc_isoc_req(dip,
    isoc_pkts_count,
    isoc_pkts_count * ep_max_pkt_size,
    USB_FLAGS_SLEEP);

/* Init each packet descriptor for maximum size. */
for (pkt = 0; pkt < isoc_pkts_count; pkt++) {
    isoc_req->isoc_pkt_descr[pkt].isoc_pkt_length = ep_max_pkt_size;

}


/* Set the length of a packet in the request too. */
isoc_req->isoc_pkts_length = ep_max_pkt_size;

/* Other isoc request initialization. */
\&...
\&...

if (usb_pipe_isoc_xfer(pipe, isoc_req, USB_FLAGS_NOSLEEP) != USB_SUCCESS) {
    ...
}
.fi
.in -2

.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Architecture	PCI-based systems
_
Interface stability	Committed
.TE

.SH SEE ALSO
.BR attributes (7),
.BR usb_alloc_request (9F),
.BR usb_get_current_frame_number (9F),
.BR usb_pipe_isoc_xfer (9F),
.BR usb_ep_descr (9S),
.BR usb_isoc_request (9S)
